package com.example.travel.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import androidx.appcompat.app.AppCompatActivity;

import com.example.travel.R;

import cn.bmob.v3.Bmob;
import cn.bmob.v3.BmobUser;
import cn.bmob.v3.listener.SaveListener;

public class Main2Activity extends AppCompatActivity {
    private EditText namea, mimaa;
    Button mButton,mButton1;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Bmob.initialize(this, "725506ecca6f5fd13ccdb5541cddf851");
        setContentView(R.layout.zhuce);

        namea = (EditText) findViewById(R.id.name1);
        mimaa = (EditText) findViewById(R.id.mima1);
        mButton = (Button) findViewById(R.id.zhuce1);
        mButton1 = (Button) findViewById(R.id.fanhui);
        mButton.setOnClickListener(new View.OnClickListener()
        {            @Override
        public void onClick(View v) {
            String etzhanghao=namea.getText().toString();
            String etmima=mimaa.getText().toString();
            User o=new User();
            o.setUsername(etzhanghao);
            o.setPassword(etmima);
            o.signUp(new SaveListener<User>() {
                @Override
                public void done(User user, cn.bmob.v3.exception.BmobException e) {
                    if (e == null) {
                        Toast.makeText(Main2Activity.this,
                                "注册成功！", Toast.LENGTH_LONG).show();
                    } else {
                        Toast.makeText(Main2Activity.this,
                                "注册失败！", Toast.LENGTH_LONG).show();
                    }
                }
            });
        }
        });
        mButton1.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent();
                intent.setClassName("com.example.travel","com.example.travel.activity.LoginActivity");//(包名)（包名.Acticity名）
                startActivity(intent);
//                    finish();
            }
        });

    }


    public static class User extends BmobUser {

    }
}






